package cn.mesmile.groovy.service.impl;

import cn.mesmile.groovy.dto.GroovyRequest;
import cn.mesmile.groovy.dto.GroovyResponse;
import cn.mesmile.groovy.service.GroovyParser;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * @author zb
 * @date 2021/11/25 16:30
 * @Description 所有脚本都需要实现  GroovyParser 接口
 */
public class CalculateGroovySimple implements GroovyParser {

	@Override
	public GroovyResponse parse(GroovyRequest request) {
		String interfaceId = request.getInterfaceId();
		Map<String, Object> extendInfo = request.getExtendInfo();
		Iterator<Map.Entry<String, Object>> iterator =
			extendInfo.entrySet().iterator();
		while (iterator.hasNext()) {
			Map.Entry<String, Object> next = iterator.next();
			System.out.println("next.getKey() = " + next.getKey());
			System.out.println("next.getValue() = " + next.getValue());
		}
		GroovyResponse groovyResponse = new GroovyResponse();
		groovyResponse.setInterfaceId(interfaceId);
		HashMap<String, Object> map = new HashMap<>();
		map.put("one", "测试二");
		map.put("two","456");
		map.put("three", false);
		groovyResponse.setExtendInfo(map);
		return groovyResponse;
	}

}
